home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls001a.1 / usr / lib / X11 / xsconfig / xsconfig.sh / xsconfig.sh
Encoding:
Text File  |  1992-04-23  |  3.0 KB  |  106 lines

  1. :
  2. # @(#) xsconfig.sh 1.7 91/11/27 
  3. #
  4. # Copyright (C) 1983-1991 The Santa Cruz Operation, Inc.
  5. #
  6. # The information in this file is provided for the exclusive use of the
  7. # licensees of The Santa Cruz Operation, Inc.  Such users have the right 
  8. # to use, modify, and incorporate this code into other products for purposes 
  9. # authorized by the license agreement provided they include this notice 
  10. # and the associated copyright notice with any such product.  The 
  11. # information in this file is provided "AS IS" without warranty.
  12. #
  13. # Purpose: 
  14. #    xsconfig.sh will use X11 and system keyboard configuration files 
  15. #    to create the server configuration file 
  16. #    '/usr/lib/X11/.Xsco.cfg'.
  17. #
  18. # Usage: 
  19. # xsconfig.sh [/usr/lib/X11/csxmaps/csxmap_file /usr/lib/keyboard/keyboard_name]
  20. #
  21. #    If the optional paramaters (csxmap and keyboard_name) are given 
  22. #     this script will call 'mapkey -c' with those paramaters, and then 
  23. #    tweak the output file to remove the  '[modifiers]' section.  
  24. #    The resulting file will be called mapkey.kbd, and it will remain 
  25. #     in the current directory.  Then, xsconfig will be called with the 
  26. #    mapkey.kbd and mod.intl.kbd files, and Mode_switch will be defined to 
  27. #    be Mod3.
  28. #
  29. #    If there are no optional paramaters, xsconfig will be called with 
  30. #     default.kbd and mod.usa.kbd files, and Mode_switch will not be defined.
  31. #
  32. #
  33. # Define return values, variables, defaults
  34. : ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
  35. tmp=/tmp/xs$$
  36.  
  37. # Define traps for critical and non critical code.
  38. trap 'echo "\nInterrupted! Exiting ..."; cleanup $FAIL' 1 2 3 15
  39.  
  40. # if stoped, try to mop up.
  41. cleanup() {
  42.     trap '' 1 2 3 15
  43.     [ "$tmp" ] && rm -f $tmp*
  44.     exit $1
  45. }
  46. Usage() {
  47.     echo "Usage:" 
  48.     echo "xsconfig.sh [/usr/lib/X11/csxmaps/csxmap_file /usr/lib/keyboard/keyboard_name]"
  49.     exit $FAIL
  50. NoFile() {
  51.     echo "$prog: Error, cannot open file <$1>"
  52.     Usage
  53.  
  54. # edit the input file to delete the '[modifiers]' section.
  55. remove_modifiers()
  56.     awk 'BEGIN { in_modifiers= 0; } 
  57.     /^\[modifiers\]/      { in_modifiers++; continue; }
  58.     /^\[/             { in_modifiers= 0; }
  59.                 { if (in_modifiers) continue; 
  60.                   else  print $0 } 
  61.     ' $1 > $2
  62.     return $?
  63. }
  64.  
  65. #
  66. # main()
  67. #
  68. prog=$0
  69. cd /usr/lib/X11/xsconfig
  70.  
  71. KBD_FILE=default.kbd        # setup the defaults for USA
  72. MOD_FILE=mod.usa.kbd
  73.  
  74. # see if we are setting up an International keyboard configuration
  75. [ $# -gt 0 ] && { 
  76.     CSXMAP=$1  ;    [ -z "$CSXMAP" ] && Usage 
  77.     KEYBOARD=$2;     [ -z "$KEYBOARD" ] && Usage 
  78.     # make sure the files exist.
  79.     [ -f "$CSXMAP" ] || NoFile $CSXMAP 
  80.     [ -f "$KEYBOARD" ] || NoFile $KEYBOARD 
  81.  
  82.     # run 'mapkey -c' to generate the mapkey.kbd file.
  83.     mapkey -c $CSXMAP $KEYBOARD > $tmp
  84.  
  85.     # don't forget to strip out the modifiers section 
  86.     remove_modifiers $tmp mapkey.kbd 
  87.     
  88.     # and one more thing, change the Alt_R to Mode_switch
  89.     mv mapkey.kbd $tmp
  90.     sed -e "s/XK_Alt_R/XK_Mode_switch/g" $tmp > mapkey.kbd
  91.  
  92.     # use the new file we created, and the intl modifier file
  93.     KBD_FILE=mapkey.kbd
  94.     MOD_FILE=mod.intl.kbd
  95.  
  96. # just do it.
  97. /usr/bin/X11/xsconfig -o /usr/lib/X11/.Xsco.cfg config.txt \
  98.     trans101.kbd $KBD_FILE misc.kbd $MOD_FILE     || cleanup $FAIL
  99.  
  100. cleanup $OK
  101.